package com.weather.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.weather.util.BaiduWeatherUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class WeatherController {

    @GetMapping("/getInfo/{cityId}")
    public JSONObject weatherInfo(@PathVariable("cityId") int city){
        String weather = BaiduWeatherUtil.getWeather(city);
        JSONObject jsonObject = JSON.parseObject(weather);
        return jsonObject;
    }

}
